<template>
  <lc-chart-sun-burst
    ref="sunBurstRef"
    :options="sunBurstOptions"
    :map-options="sunBurstMapOptions"
    :data="sunBurstData"
    style="--height: 300px"
  ></lc-chart-sun-burst>
</template>

<script setup>
import { ref } from "vue";

import { request } from "@/apis/request";
defineOptions({
  name: "SunBurst",
});

const sunBurstRef = ref(null);
const sunBurstData = ref([]);
const sunBurstMapOptions = ref({});
const sunBurstOptions = ref({
  title: { text: "", top: 10, left: 10 },
  grid: {
    left: "6%",
    top: "20%",
    right: "5%",
    bottom: "10%",
    containLabel: true,
  },
  tooltip: { trigger: "item", formatter: "" },
  visualMap: {
    type: "continuous",
    min: 0,
    max: 10,
    inRange: {
      color: [
        "rgba(62, 115, 241, 1)",
        "rgba(72, 192, 179, 1)",
        "rgba(123, 185, 44, 1)",
        "rgba(254, 216, 49, 1)",
        "rgba(243, 113, 50, 1)",
        "rgba(240, 54, 62, 1)",
        "rgba(250, 97, 102, 1)",
        "rgba(151, 96, 226, 1)",
      ],
    },
  },
  series: { type: "sunburst", radius: [0, "90%"], label: { rotate: "radial" } },
});

const getSunBurstData = async () => {
  try {
    let params = { url: "", method: "get", params: {} };
    const res = await request(params);
    if (res) {
      sunBurstData.value = res.data || [];
    }
  } catch (e) {
    console.error("获取数据出错: " + e);
  }
};
getSunBurstData();
</script>
